package cn.appsys.interceptor;

import cn.appsys.pojo.BackendUser;
import cn.appsys.pojo.DevUser;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MyInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        DevUser devUser=(DevUser) request.getSession().getAttribute("devUserSession");
        BackendUser backendUser=(BackendUser) request.getSession().getAttribute("userSession");

        if (null!=devUser){
            return true;
        }else if (null!=backendUser){
            return true;
        }else {
            response.sendRedirect(request.getContextPath()+"/403.jsp");
            return false;
        }
    }
}
